<!DOCTYPE html>
<html lang="zh-cn">
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="Zhou Wei <zromyk@163.com>">
  <title>数学-高等数学 6 第15讲 微分方程</title>
  <link rel="shortcut icon" href="/favicon.ico">
  <link rel="stylesheet" href="/style/html/pure.css">
  <link rel="stylesheet" href="/style/html/main.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
  <!-- <link rel="stylesheet" href="https://apps.bdimg.com/libs/highlight.js/9.1.0/styles/default.min.css"> -->
<link rel="stylesheet" href="/style/article/highlight/default.min.css">
<link rel="stylesheet" href="/style/article/pell-1.0.6/dist/pell.css">

</head>
<body>
  <div id="menu-background"></div>
  <div id="menu">
    <div class="pure-menu pure-menu-horizontal">
  <ul class="pure-menu-list block-middle">
    <li class="pure-menu-item">
  <a class="pure-menu-heading" href="/index.html">ZROMYK</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/index.html">主页</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/archive/index.html">归档</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/download/index.html">下载</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/feedback/index.html">反馈</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/about/index.html">关于我</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="https://github.com/zromyk"><i class="fa fa-github" style="font-size:32px"></i></a>
</li>

  </ul>
</div>

  </div>
  <div id="layout">
    <div class="content">
      <div id="nav">
    <div id="navigation" class="navigation">
  <ul class="pure-menu-list">
    <li class="pure-menu-item">
  <a class="pure-menu-link nav2" onclick="animateByNav()" href="#15">第15讲 微分方程</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#1">1. 一阶微分方程的求解</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#1_1">（1）换元</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#2">（2）齐次线性</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#3">（3）非齐次线性</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#4">（4）伯努利方程</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#2_1">2. 二阶微分方程的求解</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#1_2">（1）齐次线性方程的通解</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#22">（2）欧拉方程（2阶）</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#3-ypyqyfx">（3）非齐次线性方程  <script type="math/tex"> y''+py'+qy=f(x) </script>  的通解</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#4-ypyqyf_1xf_2x">（4）非齐次线性方程  <script type="math/tex"> y''+py'+qy=f_1(x)+f_2(x)</script>  的通解</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#3_1">3. 应用</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#1_3">（1）曲线切线的斜率</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#2_2">（2）面积</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#3_2">（3）弧长</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#4-x">（4）绕 <script type="math/tex">x</script> 轴旋转体的侧面积</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#5-x">（5）绕 <script type="math/tex">x</script> 轴旋转体的体积</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#6-y">（6）绕 <script type="math/tex">y</script> 轴旋转体的体积</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#7">（7）平均值</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#8">（8）曲率</a>
</li>

  </ul>
</div>

</div>
<div id="content-articles">
  <h1 id="数学-高等数学 6 第15讲 微分方程" class="content-subhead">数学-高等数学 6 第15讲 微分方程</h1>
  <p>
    <span>1970-01-01</span>
    <span><span class="post-category post-category-math">Math</span></span>
    <button id="button-markdownEditor" class="pure-button" onclick="markdownEditor()">启用编辑</button>
    <button id="button-save" class="pure-button" onclick="save()">保存</button>
  </p>
  <div id="content-articles-markdownEditor" style="display: none;">
    <h1>编辑 power by pell</h1>
    <div id="editor" class="pell"></div>
    <div style="margin-top:20px;">
        <h3>Text output:</h3>
        <div id="text-output"></div>
    </div>
    <div style="margin-top:20px;">
        <h3>HTML output:</h3>
        <pre id="html-output"></pre>
    </div>
  </div>
  <div id="content-articles-markdown">
    <h2 id="15">第15讲 微分方程</h2>
<blockquote class="content-quote">
<p>微分方程的通解：若微分方程的解中含有任意常数，且任意常数的 <strong>个数</strong> 与微分方程的 <strong>阶数</strong> <strong>相同</strong>，则称之为微分方程的通解。</p>
</blockquote>
<h3 id="1">1. 一阶微分方程的求解</h3>
<h4 id="1_1">（1）换元</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y'&=f(x)g(y) \\[3ex]
y'&=f(ax+by+c) \ \ \ \ \ \ \ \ \ \ &u=ax+by+c\\[2ex]
y'&=f(\cfrac{y}{x}) &u=\cfrac{y}{x} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\[1ex]
\cfrac{1}{y}'&=f(\cfrac{x}{y}) &u=\cfrac{x}{y} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\end{split}\end{equation}
</script>
</p>
<h4 id="2">（2）齐次线性</h4>
<p>
<script type="math/tex; mode=display">
y'+p(x)y=0 \\[2em]
\underline{方程两边同时乘以：e^{\int{p(x)dx}}} \\[2em]
y = Ce^{-\int{p(x)dx}}
</script>
</p>
<h4 id="3">（3）非齐次线性</h4>
<p>
<script type="math/tex; mode=display">
y'+p(x)y=q(x)
</script>
</p>
<p>
<script type="math/tex; mode=display">
\underline{方程两边同时乘以：e^{\int{p(x)dx}}}
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
e^{\int{p(x)dx}}y'+e^{\int{p(x)dx}}p(x)y &= e^{\int{p(x)dx}}q(x) \\[3ex]
                    [e^{\int{p(x)dx}}y]' &= e^{\int{p(x)dx}}q(x) \\[3ex]
                       e^{\int{p(x)dx}}y &= \int{e^{\int{p(x)dx}}q(x)}+C \\[3ex]
                                       y &= e^{-\int{p(x)dx}}[\int{e^{\int{p(x)dx}}q(x)}+C]
\end{split}\end{equation}
</script>
</p>
<h4 id="4">（4）伯努利方程</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y'+p(x)y &= q(x)y^n \\[2em]
\Rightarrow y^{-n}y'+p(x)y^{1-n} &= q(x) \\[2em]
设\ \ z &= y^{1-n} \\[2ex]
z_x'&= (1-n)y^{-n}y' \\[1ex]
\cfrac{1}{1-n}z_x' &= y^{-n}y' \\[2em]
\Rightarrow \cfrac{1}{1-n}z_x'+p(x)z &= q(x) \\[2em]
\Rightarrow z_x'+(1-n)p(x)z &= (1-n)q(x)
\end{split}\end{equation}
</script>
</p>
<h3 id="2_1">2. 二阶微分方程的求解</h3>
<h4 id="1_2">（1）齐次线性方程的通解</h4>
<p>
<script type="math/tex; mode=display">
y''+py'+qy=0
</script>
</p>
<p>若 <script type="math/tex"> p^2 - 4q \gt 0 </script> ，设 <script type="math/tex"> \lambda_1,\lambda_2 </script> 是特征方程的两个不等实根，即 <script type="math/tex"> \lambda_1\neq\lambda_2 </script> ，可得其通解为<br />
<script type="math/tex; mode=display">
y = C_1e^{\lambda_1x} + C_2e^{\lambda_2x}
</script>
<br />
若 <script type="math/tex"> p^2 - 4q = 0 </script> ，设 <script type="math/tex"> \lambda_1,\lambda_2 </script> 是特征方程的两个相等实根，即二重根，令 <script type="math/tex"> \lambda_1=\lambda_2=\lambda </script> ，可得其通解为<br />
<script type="math/tex; mode=display">
y = (C_1 + C_2x) e^{\lambda x}
</script>
<br />
若 <script type="math/tex"> p^2 - 4q \lt 0 </script> ，设 <script type="math/tex"> \alpha\pm\beta i </script> 是特征方程的一对共轭复根，可得其通解为<br />
<script type="math/tex; mode=display">
y =e^{\alpha x}(C_1\cos\beta x + C_2\sin\beta x)
</script>
</p>
<h4 id="22">（2）欧拉方程（2阶）</h4>
<p>
<script type="math/tex; mode=display">
x^2y''+pxy'+qy=0
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
换元：\ \ x&=e^t \\[2ex]
y_t'&=y_x'x_t' \\[1ex]
&=y_x'e^t \\[1ex]
&=xy_x' \\[2ex]
y_{tt}''&=x_t'y_x'+xy_{xx}''x_t' \\[1ex]
&=e^ty_x'+xy_{xx}''e^t \\[1ex]
&=xy_x'+x^2y_{xx}'' \\[1ex]
&=y_t'+x^2y_{xx}''
\end{split}\end{equation}
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
x^2y''+pxy'+qy&=0 \\[1ex]
y_{tt}''-y_t'+py_t'+qy&=0 \\[1ex]
求\ y(t)\ 得\ y(x)
\end{split}\end{equation}
</script>
</p>
<blockquote class="content-quote">
<p>欧拉方程<br />
<script type="math/tex; mode=display">
x^ny^{(n)}+p_1x^{n-1}y^{(n-1)}+...+p_{n-1}xy'+p_ny=f(x) \\[1ex]
当 x>0,换元：x=e^t \\[1ex]
当 x<0,换元：x=-e^t
</script>
</p>
</blockquote>
<h4 id="3-ypyqyfx">（3）非齐次线性方程  <script type="math/tex"> y''+py'+qy=f(x) </script>  的通解</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\big\{y''+py'+qy=f(x)的通解\big\}
= \ \ &\big\{y''+py'+qy=0的通解\big\} \\
+ &\big\{y''+py'+qy=f(x)的特解\big\}
\end{split}\end{equation}
</script>
</p>
<p>当 <script type="math/tex"> f(x) = e^{ax}P_n(x) </script> 时，设特解为 <script type="math/tex"> y^{*} = e^{ax}Q_n(x)x^k </script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{cases}
e^{ax}\text{照抄} \\[2ex]
Q_n(x)\text{为x的n次多项式的一般形式} \\[2ex]
k = 
\begin{cases}
0,\ \alpha\neq\lambda_1,\alpha\ne\lambda_2\\[2ex]
1,\ \alpha=\lambda_1\text{或}\alpha=\lambda_2\\[2ex]
2,\ \alpha=\lambda_1=\lambda_2
\end{cases}
\end{cases}
</script>
</p>
<p>当 <script type="math/tex"> f(x) = e^{ax}[P_m(x)\cos\beta x + P_n(x)\sin\beta x] </script> 时，设特解为 <script type="math/tex"> y^{*} = e^{ax}[Q_l^{(1)}(x)\cos\beta x + Q_l^{(2)}\sin\beta x]x^k </script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{cases}
e^{ax}\text{照抄} \\[2ex]
M=\max\{m,n\} \\[2ex] 
Q_M^{(1)},Q_M^{(2)}\text{为x的两个不同的M次多项式的一般形式} \\[2ex]
k = 
\begin{cases}
0,\ \alpha\pm\beta \text{i不是特征根} \\[2ex]
1,\ \alpha\pm\beta \text{i是特征根}
\end{cases}
\end{cases}
</script>
</p>
<h4 id="4-ypyqyf_1xf_2x">（4）非齐次线性方程  <script type="math/tex"> y''+py'+qy=f_1(x)+f_2(x)</script>  的通解</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\big\{y''+py'+qy=f_1(x)+f_2(x)的通解\big\}
= \ \ &\big\{y''+py'+qy=0的通解\big\} \\
+ &\big\{y''+py'+qy=f_1(x)的特解\big\} \\
+ &\big\{y''+py'+qy=f_2(x)的特解\big\}
\end{split}\end{equation}
</script>
</p>
<blockquote class="content-quote">
<p>微分算子法：<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y''+py'+y
&=e^{\alpha x} & (1)\\[1ex]
&=\sin{\beta x},\ \ \ \cos{\beta x} & (2)\\[1ex]
&=P_n(x) & (3)\\[1ex]
&=e^{\alpha x}\sin{\beta x},\ \ \ e^{\alpha x}\cos{\beta x} & (4)\\[1ex]
&=P_n(x)e^{\alpha x} & (5)\\[1ex]
&=P_n(x)\sin{\beta x},\ \ \ P_n(x)\cos{\beta x} & (6)\\[1ex]
\end{split}\end{equation}
</script>
<br />
（1）<script type="math/tex">y''+py'+y=e^{\alpha x}</script>，<script type="math/tex">D=\alpha</script>
<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y''+y&=3e^{2x} \\[1em]
(D^2+1)y^*&=3e^{2x} \\[1ex]
y^*&=\cfrac{1}{D^2+1}3e^{2x} \\[1ex]
&=\cfrac{1}{2^2+1}3e^{2x} \\[1ex]
&=\cfrac{3}{5}e^{2x} \\[3em]
y''-3y'+2y&=e^{2x} \\[1em]
(D^2-3D+2)y^*&=e^{2x} \\[1ex]
y^*&=\cfrac{1}{D^2-3D+2}e^{2x} \\[1ex]
&=\cfrac{1}{2^2-3×2+2}e^{2x} \ \ (分母为0，分母求导，提x)\\[1ex]
&=x\cfrac{1}{2D-3}e^{2x} \\[1ex]
&=x\cfrac{1}{2×2-3}e^{2x} \\[1ex]
&=xe^{2x} \\[3em]
y''+2y'+y&=2e^{-x} \\[1em]
(D^2+2D+1)y^*&=2e^{-x} \\[1ex]
y^*&=\cfrac{1}{D^2+2D+1}2e^{-x} \\[1ex]
&=\cfrac{1}{(-1)^2+2(-1)+1}2e^{-x} \ \ (分母为0，分母求导，提x)\\[1ex]
&=x\cfrac{1}{2D+2}2e^{-x} \\[1ex]
&=x\cfrac{1}{2(-1)+2}2e^{-x} \ \ (分母为0，分母求导，提x)\\[1ex]
&=x^2\cfrac{1}{2}2e^{-x} \\[1ex]
\end{split}\end{equation}
</script>
<br />
（2）<script type="math/tex">y''+py'+y=\sin{\beta x},\ \ \ \cos{\beta x}</script>，<script type="math/tex">D^2=-{\beta}^2</script>
<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y''+y&=3\sin{3x} \\[1em]
(D^2+1)y^*&=3\sin{3x} \\[1ex]
y^*&=\cfrac{1}{D^2+1}3\sin{3x} \\[1ex]
&=\cfrac{1}{-3^2+1}3\sin{3x} \\[1ex]
&=-\cfrac{3}{8}\sin{3x} \\[3em]
y''+4y&=3\cos{2x} \\[1em]
(D^2+4)y^*&=3\cos{2x} \\[1ex]
y^*&=\cfrac{1}{D^2+4}3\cos{2x} \\[1ex]
&=\cfrac{1}{-2^2+4}3\cos{2x} \ \ (分母为0，分母求道，提x)\\[1ex]
&=x\cfrac{1}{2D}\cos{2x} \\[1ex]
&=\cfrac{x}{2}\int\cos{2x} \\[3em]
y''+3y'-2y&=\sin{2x} \\[1em]
(D^2+3D-2)y^*&=\sin{2x} \\[1ex]
y^*&=\cfrac{1}{D^2+3D-2}3\sin{2x} \\[1ex]
&=\cfrac{1}{3D-6}\sin{2x} \\[1ex]
&=\cfrac{1}{3}\cfrac{1}{D-2}\sin{2x} \\[1ex]
&=\cfrac{1}{3}\cfrac{D+2}{D^2-4}\sin{2x} \\[1ex]
&=\cfrac{1}{3}\cfrac{D+2}{-8}\sin{2x} \\[1ex]
\end{split}\end{equation}
</script>
<br />
（3）<script type="math/tex">y''+py'+y=P_n(x)</script>
<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y''+y&=x^2-3x+1 \\[1em]
(D^2+1)y^*&=x^2-3x+1 \\[1ex]
y^*&=\cfrac{1}{D^2+1}(x^2-3x+1) \\[1ex]
&=\sum{(-D^2)}^n(x^2-3x+1) \\[1ex]
&=(1-D^2)(x^2-3x+1) \\[1ex]
&=x^2-3x+1-2 \\[1ex]
&=x^2-3x-1 \\[1ex]
\end{split}\end{equation}
</script>
<br />
（4）（5）<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
y''+py'+y
&=e^{\alpha x}\sin{\beta x},\ \ \ e^{\alpha x}\cos{\beta x} & (4)\\[1ex]
&=P_n(x)e^{\alpha x} & (5)\\[3em]
y^*&=\cfrac{1}{F(D)}e^{\alpha x}\sin{\beta x} \\[1ex]
&=e^{\alpha x}\cfrac{1}{F(D+\alpha)}\sin{\beta x} \\[3em]
y^*&=\cfrac{1}{F(D)}e^{\alpha x}P_n(x) \\[1ex]
&=e^{\alpha x}\cfrac{1}{F(D+\alpha)}P_n(x) \\[3em]
\end{split}\end{equation}
</script>
<br />
</p>
</blockquote>
<h3 id="3_1">3. 应用</h3>
<h4 id="1_3">（1）曲线切线的斜率</h4>
<p>
<script type="math/tex; mode=display">
f'(x)\bigg|_{x=x_0}=\tan\alpha
</script>
</p>
<h4 id="2_2">（2）面积</h4>
<p>
<script type="math/tex; mode=display">
S = \int_a^b f(x)dx
</script>
</p>
<h4 id="3_2">（3）弧长</h4>
<p>
<script type="math/tex; mode=display">
L = \int_a^b\sqrt{1+(f_x')^2}dx
</script>
</p>
<h4 id="4-x">（4）绕 <script type="math/tex">x</script> 轴旋转体的侧面积</h4>
<p>
<script type="math/tex; mode=display">
S_{绕x轴旋转体侧} = 2\pi r·h = 2\pi\int_a^b\bigg|f(x)\bigg|\ \sqrt{1+(f_x')^2}\ dx
</script>
</p>
<h4 id="5-x">（5）绕 <script type="math/tex">x</script> 轴旋转体的体积</h4>
<p>
<script type="math/tex; mode=display">
V_x = \pi r^2 = \pi\int_a^b f^2(x)dx
</script>
</p>
<h4 id="6-y">（6）绕 <script type="math/tex">y</script> 轴旋转体的体积</h4>
<p>
<script type="math/tex; mode=display">
V_y = 2\pi r·h = 2\pi\int_a^b x\bigg|f(x)\bigg|dx
</script>
</p>
<h4 id="7">（7）平均值</h4>
<p>
<script type="math/tex; mode=display">
\overline f = \cfrac{1}{b-a} \int_a^b f(x)dx = f(\xi)
</script>
</p>
<h4 id="8">（8）曲率</h4>
<p>
<script type="math/tex; mode=display">
k=\cfrac{|f''|}{[1+(f')^2]^{\frac{3}{2}}}
</script>
</p>
  </div>
</div>
 
    </div>
  </div>
  <div id="footer-background">
    <div id="footer">
      <div class="legal pure-g">
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-license"><a href="https://beian.miit.gov.cn/#/Integrated/index">浙ICP备2020038748号</a></p>
  </div>
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-links"><a href="https://github.com/zromyk">GitHub</a></p>
    <p class="legal-copyright">Copyright © 2021 Wei Zhou. 保留所有权利。</p>
  </div>
</div>
    </div>
  </div>
  <!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
  <script src="/style/html/jquery.min.js"></script>
  <script src='/style/article/latex/latest.js?config=TeX-MML-AM_CHTML'></script>
<!-- <script src="https://cdn.geogebra.org/apps/deployggb.js"></script> -->
<script src="/style/article/deployggb.js"></script>
<!-- <script src="https://apps.bdimg.com/libs/highlight.js/9.1.0/highlight.min.js"></script> -->
<script type="text/javascript">
  // 脚本：navigation 随鼠标移动自动变换宽度
  var element = document.getElementById("navigation"); // 获取要操作的元素
  var elementWidth = parseInt(getComputedStyle(element).width);
  var elementLeft = 0;
  var elementRight = 0;
  element.addEventListener('mouseenter', function (event) { // 添加鼠标按下事件的监听器
    elementLeft = element.getBoundingClientRect().left - 10;
    elementRight = element.getBoundingClientRect().left + elementWidth * 3;
    window.addEventListener('mousemove', resize); // 添加全局的鼠标移动事件的监听器
  });

  function resize(event) {
    var minWidth = elementWidth;
    var maxWidth = elementWidth * 2.5;
    // console.log(elementLeft, event.clientX, elementRight, event.clientX - elementLeft + elementWidth / 2);
    if (elementLeft <= event.clientX && event.clientX <= elementRight) {
      var width = event.clientX - elementLeft + elementWidth / 2;
      width = Math.min(width, maxWidth);
      width = Math.max(width, minWidth);
      element.style.width = width + 'px'; // 设置新的宽度样式属性
    }
    else {
      element.style.width = elementWidth + 'px'; // 设置新的宽度样式属性
      stopResize();
    }
  }

  function stopResize() {
    element.style.width = elementWidth + 'px'; // 设置新的宽度样式属性
    // console.log("stopResize", elementLeft, event.clientX, elementRight, event.clientX - elementLeft + elementWidth / 2);
    window.removeEventListener('mousemove', resize); // 移除鼠标移动事件的监听器
  }
</script>
<script src="/style/article/highlight/highlight.min.js"></script>
<script type="text/javascript">
  // 脚本：code语法高亮
  hljs.initHighlightingOnLoad();
</script>
<script>
  function animateByNav() {
    $("html").animate({
        scrollTop: ($(event.target.hash).offset().top - 52)
    }, 300);
  };
</script>
<script src="/style/article/pell-1.0.6/dist/pell.js"></script>
<script>
  // 脚本：自由编辑页面
  var editor = window.pell.init({
    element: document.getElementById('editor'),
    defaultParagraphSeparator: 'p',
    onChange: function(html) {
        document.getElementById('text-output').innerHTML = html
        document.getElementById('html-output').textContent = html
    }
  });

  function markdownEditor() {
    var articles = document.getElementById('content-articles-markdown');
    if (articles.getAttribute("contenteditable") == "true") {
        articles.setAttribute("contenteditable", "false");
        document.getElementById("content-articles-markdownEditor").style.display = "none"; //隐藏
        document.getElementById("button-markdownEditor").innerHTML = "启用编辑";
    } else {
        articles.setAttribute("contenteditable", "true");
        document.getElementById("content-articles-markdownEditor").style.display = ""; //显示
        document.getElementById("button-markdownEditor").innerHTML = "关闭编辑";
    }
  };

  function save() {
      window.alert("保存成功");
  };
</script>

</body>
</html>
